// FooterComponent.js
import React, { useEffect, useState } from 'react'
import { Table } from 'antd'
import axios from 'axios'

const FooterComponent = () => {
  const [dataSource, setDataSource] = useState([])

  useEffect(() => {
    // 从 Node.js 模拟 API 获取数据
    const fetchData = async () => {
      try {
        const response = await axios.get('http://localhost:5000/api/data')
        setDataSource(response.data)
      } catch (error) {
        console.error('Error fetching data', error)
      }
    }

    fetchData()
  }, [])

  const columns = [
    {
      title: '星期',
      dataIndex: 'day',
      key: 'day',
    },
    {
      title: '早上',
      dataIndex: 'morning',
      key: 'morning',
    },
    {
      title: '中午',
      dataIndex: 'noon',
      key: 'noon',
    },
    {
      title: '晚上',
      dataIndex: 'evening',
      key: 'evening',
    },
  ]

  return <Table dataSource={dataSource} columns={columns} rowKey="time" />
}

export default FooterComponent
